/**   
 * @Title: ViewerUtil.java 
 * @Package com.esun.util 
 * @Description: (视图工具类,存放通用视图类工具) 
 * @author 程相亭 <br/>
 * @date 2012-03-13 下午05:07:33  
 * copy right 深圳市易讯天空网络技术有限公司
 */
package com.esun.util;

import com.esun.util.log.EDebug;
import com.esun.util.pngloader.AsyPngLoader;
import com.esun.util.pngloader.PngLoader;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.widget.ImageView;
import android.widget.Toast;

/**
 * com.esun.util.ViewerUtil
 * 
 * @Description: (通用工具类)
 * @author 程相亭 <br/>
 * @date 2012-04-29 下午05:07:33
 * 
 */
public class Tools {

	/**
	 * @Title: networkStatus
	 * @Description: 网络状态
	 * @param Context
	 *            context
	 * @return boolean
	 * @throws
	 */
	public static boolean networkStatus(Context context) {
		ConnectivityManager connectivityManager = (ConnectivityManager) context
				.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo mobNetInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		NetworkInfo wifiNetInfo = connectivityManager
				.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

		if (!mobNetInfo.isConnected() && !wifiNetInfo.isConnected()) {
			return false;
		} else {
			return true;
		}

	}

	/**
	 * @Title: loadLogo
	 * @Description: 加载球队Logo
	 * @param
	 * @return
	 * @throws
	 */
	public static void loadLogo(ImageView ivLogo, String url) {

		PngLoader loader = new PngLoader();
		// 加载主队LOGO
		AsyPngLoader homeAsyPngLoader = new AsyPngLoader(ivLogo);
		Drawable home = loader.getPng(url, homeAsyPngLoader);
		if (home != null) {
			EDebug.o("*********************1**************************");
			ivLogo.setBackgroundDrawable(home);
		}
	}
	public static void TipNetworkError(Context context,String tip){
		Toast.makeText(context,tip,Toast.LENGTH_SHORT).show();
	}
}
